package com.theaf.basemodule.dao;

import com.theaf.basemodule.common.model.SysPosition;
import com.theaf.core.repo.base.BaseRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @Author:songwenke
 * @Description:岗位
 * @Date:create in 16:01 2018/2/23
 * @Modified By:
 **/
public interface PositionDAO extends BaseRepository<SysPosition,Long> {
    List<SysPosition> findAllByIdIn(Long[] ids);

    @Modifying
    @Transactional
    @Query(nativeQuery=true,value = "delete from sys_pos_auth a " +
            "where EXISTS (select * from sys_resource t,sys_resource y " +
            "where t.id=a.res_id and t.level_code like y.level_code||'%' and y.id=:menuId)")
     void deleteResource(@Param("menuId") Long menuId);
}
